package com.igeekhome.microservice.feign;

import com.igeekhome.microservice.pojo.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * @author yadonghe
 * @date 2020-02-24 16:03
 */

@Component   //这里的Component 加了可能也不行
public class UserFeignServiceFallBackFactory implements FallbackFactory<UserFeignService> {
    @Override
    public UserFeignService create(final Throwable throwable) {
        return new UserFeignService() {
            @Override
            public User get(Long id) {
                return new User(id, "请求异常,请稍后再试", throwable.getMessage(),0, new BigDecimal(0));
            }
        };
    }
}
